﻿using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TimScripts.BF4Rcon.Frostbite;

namespace TimScripts.BF4Rcon.Test
{
    internal class PlayerRconClient : ISynchronousRconClient
    {
        private readonly string[] ValidSubsets = { "all", "team", "player", "squad" };
        public List<string> Players = new List<string>();

        public IList<string> SendRequest(IEnumerable<string> words)
        {
            string[] words2 = words.ToArray();
            bool adminCommand = words2[0].StartsWith("admin");
            IList<string> result;
            PlayerInfoBlockCreator data = new PlayerInfoBlockCreator();

            //subset
            Assert.True(words2.Length > 1 && ValidSubsets.Contains(words2[1], StringComparer.OrdinalIgnoreCase),
                "Invalid or nonexistent subset");

            Assert.AreEqual(IsLoggedOn, adminCommand);

            result = data.AddPlayers(Players.ToArray()).AddProperties("name", "awesomeness").CreatePlayerInfoBlock("OK").AsReadOnly();

            return result;
        }

        public bool IsLoggedOn
        {
            get;
            set;
        }

        public bool LogOn(string password)
        {
            throw new NotImplementedException();
        }



        public IList<string> SendRequest(IEnumerable<string> words, int timeout)
        {
            throw new NotImplementedException();
        }

        public IList<string> SendRequest(int timeout, params string[] words)
        {
            throw new NotImplementedException();
        }
    }
}
